package com.kerraway.model;

import com.kerraway.util.JacksonUtil;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

/**
 * @author 小柯
 * @date 2019/07/17
 */
@Data
@Entity
@Table(name = "t_order_logs")
@EntityListeners({AuditingEntityListener.class})
public class OrderLog {

  @Id
  /*@GeneratedValue(strategy = GenerationType.IDENTITY)*/
  @GeneratedValue(generator = "IdCustomGenerator")
  @GenericGenerator(name = "IdCustomGenerator", strategy = "com.kerraway.model.IdCustomGenerator")
  private Long id;

  private Integer orderId;

  private String comment;

  @CreatedDate
  private Date createdAt;
  @LastModifiedDate
  private Date updatedAt;

  @Override
  public String toString() {
    return JacksonUtil.writeValue(this);
  }
}
